#define _gam_wpn_req_included 1

#if !defined _gam_stock_included
	#include <gam/stock>
#endif

//{ WEAPON LEVEL REQUIREMENTS

stock getWeaponLevelReq(weapon, level, req[LEVEL_REQ]){
	/*
	Format:
	{KR, HR, KM, HM, KT, HT}
	KR/HR - Kills/Headshots in one round
	KM/HR - Kills/Headshots in one game (map)
	KT/HT - Kills/Headshots totally
	*/
	req = {0,0,0,0,0,0};
	switch (weapon){
		case WEAPONS_P228, WEAPONS_ELITE, WEAPONS_FIVESEVEN: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {3,1,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {0,2,0,0,70,7};
				case LEVEL_VETERAN: 	req = {0,0,0,0,100,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,150,20};
				case LEVEL_HITMAN: 	req = {0,2,0,10,200,30};
				case LEVEL_OWNER: 	req = {4,3,15,10,250,50};
			}
		}
		case WEAPONS_USP, WEAPONS_GLOCK18, WEAPONS_DEAGLE: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {3,1,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {0,2,10,0,80,7};
				case LEVEL_VETERAN: 	req = {0,0,15,0,120,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,170,30};
				case LEVEL_HITMAN: 	req = {0,2,0,12,220,40};
				case LEVEL_OWNER: 	req = {4,3,15,13,280,80};
			}
		}
		
		
		case WEAPONS_SCOUT: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,0};
				case LEVEL_BASIC: 	req = {3,0,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {3,1,0,0,80,5};
				case LEVEL_VETERAN: 	req = {0,0,15,0,120,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,150,0};
				case LEVEL_HITMAN: 	req = {0,2,0,5,200,20};
				case LEVEL_OWNER: 	req = {4,2,20,8,250,30};
			}
		}
		case WEAPONS_AWP: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,0};
				case LEVEL_BASIC: 	req = {3,0,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {3,0,0,0,80,3};
				case LEVEL_VETERAN: 	req = {0,0,10,0,120,8};
				case LEVEL_EXPERT: 	req = {4,0,15,0,150,0};
				case LEVEL_HITMAN: 	req = {4,0,0,3,200,15};
				case LEVEL_OWNER: 	req = {4,1,20,2,250,20};
			}
		}
		
		
		case WEAPONS_XM1014, WEAPONS_M3: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {2,0,10,0,40,0};
				case LEVEL_ADVANCED: 	req = {3,1,12,0,60,5};
				case LEVEL_VETERAN: 	req = {0,0,15,0,80,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,100,0};
				case LEVEL_HITMAN: 	req = {0,2,0,5,150,20};
				case LEVEL_OWNER: 	req = {4,2,20,8,200,30};
			}
		}
		
		case WEAPONS_MAC10, WEAPONS_UMP45, WEAPONS_MP5NAVY, WEAPONS_TMP, WEAPONS_P90: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {3,0,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {3,1,10,0,80,5};
				case LEVEL_VETERAN: 	req = {0,0,15,0,120,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,150,0};
				case LEVEL_HITMAN: 	req = {0,2,0,5,200,20};
				case LEVEL_OWNER: 	req = {4,2,20,8,250,30};
			}
		}
		case WEAPONS_AUG, WEAPONS_GALIL, WEAPONS_FAMAS, WEAPONS_SG552: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {3,1,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {0,2,0,0,80,5};
				case LEVEL_VETERAN: 	req = {0,0,15,0,120,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,150,0};
				case LEVEL_HITMAN: 	req = {0,2,0,8,200,30};
				case LEVEL_OWNER: 	req = {4,2,20,10,250,30};
			}
		}
		case WEAPONS_M4A1,WEAPONS_AK47: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,8,0,30,1};
				case LEVEL_BASIC: 	req = {3,1,13,0,70,0};
				case LEVEL_ADVANCED: 	req = {3,2,15,0,80,7};
				case LEVEL_VETERAN: 	req = {3,0,15,0,150,20};
				case LEVEL_EXPERT: 	req = {4,1,15,4,200,0};
				case LEVEL_HITMAN: 	req = {0,3,0,10,250,40};
				case LEVEL_OWNER: 	req = {4,3,20,10,500,100};
			}
		}
		
		case WEAPONS_HEGRENADE: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {0,0,3,0,10,0};
				case LEVEL_BASIC: 	req = {0,0,4,0,30,0};
				case LEVEL_ADVANCED: 	req = {0,0,5,0,50,0};
				case LEVEL_VETERAN: 	req = {0,0,5,0,80,0};
				case LEVEL_EXPERT: 	req = {0,0,6,0,100,0};
				case LEVEL_HITMAN: 	req = {0,0,7,0,120,0};
				case LEVEL_OWNER: 	req = {0,0,8,0,150,0};
			}
		}
		case WEAPONS_M249: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {2,0,5,0,30,1};
				case LEVEL_BASIC: 	req = {3,1,10,0,50,0};
				case LEVEL_ADVANCED: 	req = {0,2,10,0,80,7};
				case LEVEL_VETERAN: 	req = {0,0,15,0,120,10};
				case LEVEL_EXPERT: 	req = {4,0,15,0,170,0};
				case LEVEL_HITMAN: 	req = {0,2,0,8,200,30};
				case LEVEL_OWNER: 	req = {4,3,20,10,250,50};
			}
		}
		
		case WEAPONS_KNIFE: {
			switch (level){
				case LEVEL_BEGINNER: 	req = {0,0,2,0,10,0};
				case LEVEL_BASIC: 	req = {0,0,2,0,30,0};
				case LEVEL_ADVANCED: 	req = {0,0,2,0,40,0};
				case LEVEL_VETERAN: 	req = {0,0,2,0,50,2};
				case LEVEL_EXPERT: 	req = {0,1,4,0,60,3};
				case LEVEL_HITMAN: 	req = {0,0,4,2,70,5};
				case LEVEL_OWNER: 	req = {2,0,5,0,100,8};
			}
		}
		
	}
}
//}


stock bool:checkPlayerNextLevel4Weapon(id, wpn){
	if(isLevelWeapon(wpn)){
		new level = gPlayerLevelInfo[id][wpn];
		if(level < LEVEL_OWNER){
			level ++;
			new wpnReq[LEVEL_REQ];
			new req;
			new has;
			new bool:shouldGiveLevel = true;
			getWeaponLevelReq(wpn, level, wpnReq);
			
			for(new i=0;i<LEVEL_REQ;i++) {
				if(!gPlayerLevelReq[id][wpn][i]) {
					req = wpnReq[i];
					has = gPlayerInfo[id][wpn][i];
					if(has>=req)
						gPlayerLevelReq[id][wpn][i] = 1;
					else {
						shouldGiveLevel = false;
					}
				}
			}
			
			if(shouldGiveLevel){
				setClientWeaponLevel(id, wpn, level);
				return true;
			}
		}
	}
	return false;
}


stock showWeaponReq(id, wpn){
	if(isLevelWeapon(wpn)){
		new level;
		new get[LEVEL_REQ];
		if(getWeaponNextLevelReq(id, wpn, get, level)) {
			
			new levelName[32];
			if(level == LEVEL_NONE){
				ColorChat(id, RED, "%L", id, "INFO_MAX_LEVEL");
				return;
			}
			new weaponName[32];
			getWeaponName4Level(id, wpn, weaponName, 31);
			getLevelName(id, level, levelName, 31);
			new msg[128];
			new kills = get[REQ_KILLS_ROUND];
			new hs = get[REQ_HS_ROUND];
			ColorChat(id, BLUE, "^x04%L^x03 %s ^x04%L^x03 %s", id, "GUN", weaponName, id, "NEXT_LEVEL", levelName);
			
			if(kills || hs ){
				formatex(msg, charsmax(msg), "%L", id, "ROUND_REQ");
				if(kills)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "KILLS", kills);
				if(hs)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "HEADSHOTS", hs);
				
				ColorChat(id, RED, msg);
			}
			
			kills = get[REQ_KILLS_MAP];
			hs = get[REQ_HS_MAP];
			if(kills || hs ) {
				formatex(msg, charsmax(msg), "%L", id, "MAP_REQ");
				if(kills)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "KILLS", kills);
				if(hs)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "HEADSHOTS", hs);
				
				ColorChat(id, RED, msg);
			}
			
			kills = get[REQ_KILLS_TOTAL];
			hs = get[REQ_HS_TOTAL];
			if(kills || hs ){
				formatex(msg, charsmax(msg), "%L", id, "TOTAL_REQ");
				if(kills)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "KILLS", kills);
				if(hs)
					format(msg, charsmax(msg), "%s ^x04%L:^x03 %d", msg, id, "HEADSHOTS", hs);
				
				ColorChat(id, RED, msg);
			}
		}
	} else {
		ColorChat(id, RED, "%L", id, "INFO_NO_LEVEL_WPN");
	}
}

stock getWeaponNextLevelReq(id, wpn, req[LEVEL_REQ], &level){
	new bool:result = false;
	
	level = gPlayerLevelInfo[id][wpn];
	if(level != LEVEL_OWNER){

		level++;
		new wpnReq[LEVEL_REQ];
		getWeaponLevelReq(wpn, level, wpnReq);
		for(new i=0;i<LEVEL_REQ;i++){
			if(!gPlayerLevelReq[id][wpn][i]){
				req[i] =  wpnReq[i] - gPlayerInfo[id][wpn][i];
				if(req[i])
					result = true;
			}
		}
	} else {
		level = LEVEL_NONE;
	}
	
	return result;
}



